<?php

require_once 'Zend/Gdata/Extension.php';

class Raws_Extension_Content extends Zend_Gdata_Extension
{

    protected $_rootNamespace = 'atom';
    protected $_rootElement = 'content';
    protected $_params = null;
    protected $_src = null;
    
    /**
     * Create a new instance.
     * 
     * @param Zend_Gdata_Geo_Extension_GmlPoint $point (optional) Point to which
     *          object should be initialized.
     */
    public function __construct($params = null, $type = 'application/xml', $src = null)
    {
        foreach (Raws::$namespaces as $nsPrefix => $nsUri) {
            $this->registerNamespace($nsPrefix, $nsUri);
        }
        parent::__construct();
        $this->setParams($params);
        $this->_src = $src;
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = null)
    {
        $element = parent::getDOM($doc);
        // if ($this->_params !== null) {
        //     $element->appendChild($this->_params->getDOM($element->ownerDocument));
        // }
        if ($this->_src != null) {
            $element->setAttribute('src', $this->_src);
        }
        return $element;
    }
    
    protected function takeAttributeFromDOM($attribute)
    {
        switch ($attribute->localName) {
        case 'src':
            $this->_src = $attribute->nodeValue;
            break;
        default:
            parent::takeAttributeFromDOM($attribute);
        }
    }
    
    /**
     * @return Zend_Gdata_App_Extension_Src
     */
    public function getSrc()
    {
        return $this->_src;
    }

    /**
     * @param Zend_Gdata_App_Extension_Src $value
     * @return Zend_Gdata_App_Entry Provides a fluent interface
     */
    public function setSrc($value)
    {
        $this->_src = $value;
        return $this;
    }

    public function getParams()
    {
        return $this->_params;
    }

    public function setParams($value)
    {
        $this->_params = $value;
        return $this;
    }

}
